package com.wbs.service.impl;

import com.wbs.mapper.TbGoodsDescMapper;
import com.wbs.mapper.TbGoodsMapper;
import com.wbs.model.TbGoodsDesc;
import com.wbs.service.GoodsDescService;
import com.wbs.vo.GoodsDescVO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author: 芝梦
 * @Description:
 * @DateTime: 2024/1/31 18:02
 */
@Service
public class GoodsDescServiceImpl implements GoodsDescService {
    @Autowired
    private TbGoodsDescMapper tbGoodsDescMapper;

    @Override
    public void add(GoodsDescVO goodsDescVO) {
        //类型转换
        TbGoodsDesc tbGoodsDesc = this.conversionTb(goodsDescVO);
        tbGoodsDescMapper.insertSelective(tbGoodsDesc);
    }

    @Override
    public GoodsDescVO selectByPrimaryKey(Long goodsId) {
        return this.conversionVO(tbGoodsDescMapper.selectByPrimaryKey(goodsId));
    }

    /*辅助方法----------------------------------------------------------------------------------------------------*/
    //转换为Tb
    private TbGoodsDesc conversionTb(GoodsDescVO goodsDescVO){
        TbGoodsDesc tbGoodsDesc = new TbGoodsDesc();
        BeanUtils.copyProperties(goodsDescVO,tbGoodsDesc);
        return tbGoodsDesc;
    }
    //转换为Tb
    private GoodsDescVO conversionVO(TbGoodsDesc tbGoodsDesc){
        GoodsDescVO goodsDescVO = new GoodsDescVO();
        BeanUtils.copyProperties(tbGoodsDesc,goodsDescVO);
        return goodsDescVO;
    }
    
}
